Check if dictionary is empty or notΒΆ
not bool(D)
Check if dictionary is empty or not.
D = {}
if not bool(D):
print("Dictionary is empty")
Output:
Dictionary is empty
not bool(D)
D = {}
if not bool(D):
print("Dictionary is empty")
Output:
Dictionary is empty